package com.linghang.wusthelpercompetition.utils;

import com.linghang.wusthelpercompetition.service.MyTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;

@Service
public class GetIdentityService {
    @Autowired
    private MyTokenService tokenService;
    public static String getUidFromSecurityContext() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(principal instanceof String uid)
            return uid;
        return null;
    }
}
